#ifndef _UTILS_H_
#define _UTILS_H_

//NOTE: 'num_pints' is actually num_pints * 128
//The reason for this is that with a maximum of 99 pints dispalyed,
//you can fit 99 * 5 * 128 into a uint16_t.  This makes the averaging calculation easier
extern uint16_t num_pints[8];

extern void start_next_freq_capture();
extern uint32_t get_ccp_frequency();
extern uint32_t get_keg_level(uint8_t keg_num);

void read_keginfo(uint8_t keg_num);
extern void update_values();

extern struct keginfo_s keginfo;

#define ASSIGN_24(res,b8,b16,b24) \
    asm movf _##b8, W  \
    asm movwf _##res   \
    asm movf _##b16, W \
    asm movwf _##res+1 \
    asm movf _##b24, W \
    asm movwf _##res+2 \
    asm movlw 0x00   \
    asm movwf _##res+3

#endif

#define CALC_KEG_EMPTY()   (keginfo.keg_full - keginfo.hz_per_pint * keginfo.max_pints)
#define CALC_HZ_PER_PINT() ((keginfo.keg_full - keginfo.keg_empty) / keginfo.max_pints)
